import pymysql
from Config import Config
class SwitchedModel:
    def __init__(self,id = None,switchs = None,describe = None):
        self.id = id
        self.switchs = switchs
        self.describe = describe
    @staticmethod
    def get_all():
        config = Config()
        db_config = config.get_config()
        connection = pymysql.connect(**db_config)
        try:
            with connection.cursor() as cursor:
                sql = "SELECT * FROM switched"
                cursor.execute(sql)
                result = cursor.fetchall()
                return [SwitchedModel(**row) for row in result]
        finally:
            connection.close()

